package yawning.mew.gui.characters.equipment;

import javax.swing.JPanel;

import yawning.mew.equipment.Item;
import yawning.mew.equipment.RawItem;
import yawning.mew.equipment.EquipSet.Slot;
import yawning.mew.gui.tools.CharacterDataSource;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.RowSpec;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.SwingConstants;

public class ItemSlot extends JPanel {
	private CharacterDataSource source;
	private Slot slot;
	private JLabel lblEnchantement;
	private JTextField txtGems1;
	private JTextField txtGems2;
	private JTextField txtGems3;
	private JTextField txtGems4;
	private JTextField txtColor1;
	private JTextField txtColor2;
	private JTextField txtColor3;
	private JTextField txtColor4;
	private JTextField txtItemName;
	private JCheckBox cbxGemSlot;
	
	public Slot getSlot() {
		return slot;
	}
	/**
	 * Create the panel.
	 */
	public ItemSlot(Slot slot, CharacterDataSource source) 
	{
		this.source = source;
		this.slot = slot;
		setLayout(new FormLayout(new ColumnSpec[] {
				ColumnSpec.decode("82px"),
				ColumnSpec.decode("105px:grow"),
				FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
				ColumnSpec.decode("107px:grow"),
				FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
				ColumnSpec.decode("109px:grow"),},
			new RowSpec[] {
				FormFactory.LINE_GAP_ROWSPEC,
				RowSpec.decode("20px"),
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		JLabel lblNom = new JLabel(slot.toString());
		add(lblNom, "1, 2, center, center");
		
		txtItemName = new JTextField();
		add(txtItemName, "2, 2, fill, default");
		txtItemName.setColumns(10);
		
		JLabel lblGems = new JLabel("Gems");
		add(lblGems, "4, 2, center, default");
		
		JLabel lblColor = new JLabel("Color");
		add(lblColor, "6, 2, center, default");
		
		lblEnchantement = new JLabel("Enchantement");
		add(lblEnchantement, "1, 4, center, default");
		
		JComboBox cmbEnchants = new JComboBox();
		add(cmbEnchants, "2, 4, fill, default");
		
		txtGems1 = new JTextField();
		add(txtGems1, "4, 4, fill, default");
		txtGems1.setColumns(10);
		
		txtColor1 = new JTextField();
		add(txtColor1, "6, 4, fill, default");
		txtColor1.setColumns(10);
		
		JLabel lblReforging = new JLabel("Reforging");
		add(lblReforging, "1, 6, center, default");
		
		JComboBox txtReforging = new JComboBox();
		add(txtReforging, "2, 6, fill, default");
		
		txtGems2 = new JTextField();
		add(txtGems2, "4, 6, fill, default");
		txtGems2.setColumns(10);
		
		txtColor2 = new JTextField();
		add(txtColor2, "6, 6, fill, default");
		txtColor2.setColumns(10);
		
		JLabel lblAdditionnalGem = new JLabel("Added Gem Slot");
		add(lblAdditionnalGem, "1, 8, center, default");
		
		cbxGemSlot = new JCheckBox("");
		add(cbxGemSlot, "2, 8");
		
		txtGems3 = new JTextField();
		add(txtGems3, "4, 8, fill, default");
		txtGems3.setColumns(10);
		
		txtColor3 = new JTextField();
		add(txtColor3, "6, 8, fill, default");
		txtColor3.setColumns(10);
		
		txtGems4 = new JTextField();
		add(txtGems4, "4, 10, fill, default");
		txtGems4.setColumns(10);
		
		txtColor4 = new JTextField();
		add(txtColor4, "6, 10, fill, default");
		txtColor4.setColumns(10);
		
		
	}
	
	private void init()
	{
		Item item =source.getItem(slot);
		txtItemName.setText(item.mItem.name);
		txtItemName.setToolTipText(item.mItem.name);
				
	}
}
